package controller;

import model.MySql;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 按类型获取书籍;
 * Created by yvdedu.com on 2016/10/8.
 */
@WebServlet(urlPatterns = "/getbook_bytype")
public class getbook_bytype extends HttpServlet{
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        req.setCharacterEncoding("utf-8");
        String type=req.getParameter("type");
        String page =req.getParameter("page");
        MySql mySql=new MySql();
        req.setAttribute("getbook_bytype",mySql.getBooksByType(type, Integer.parseInt(page)));
        req.getRequestDispatcher("index.jsp").forward(req,resp);
    }
}
